package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Customize;
import cn.wolfcode.trip.base.domain.Region;
import cn.wolfcode.trip.base.mapper.CustomizeMapper;
import cn.wolfcode.trip.base.mapper.RegionMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.ICustomizeService;
import cn.wolfcode.trip.base.service.IRegionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomizeServiceImpl implements ICustomizeService {

    @Autowired
    CustomizeMapper customizeMapper;

    @Override
    public void save(Customize customize) {
       if(customize.getId()==null){
           customize.setState(10);
           customizeMapper.insert(customize);
       }else {
           System.out.println("------------------");
           customizeMapper.updateByPrimaryKey(customize);
       }
    }

    @Override
    public Customize get(Long userId) {
        return customizeMapper.selectByPrimaryKey(userId);
    }

    @Override
    public PageInfo<Customize> list(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Customize> list= customizeMapper.list(qo);
        return new PageInfo<>(list);
    }

    @Override
    public void update(Long state,Long id) {
        customizeMapper.update(state,id);
    }


}
